/*
 * @lc app=leetcode.cn id=509 lang=typescript
 *
 * [509] 斐波那契数
 */

// @lc code=start
function fib(n: number): number {
    if (n < 2) return n;
    let i = 0;
    let j = 1;
    let count = 2;
    while (count <= n) {
        [i, j] = [j, i + j];
        count++;
    }
    return j;
}
// @lc code=end
